package com.vfconsulting.common.service;

import java.util.HashMap;
import java.util.List;

import javax.persistence.EntityManager;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.vfconsulting.common.model.CtlAudit2g;
import com.vfconsulting.common.model.repository.CtlAudit2gRepository;
import com.vfconsulting.util.Utilitario;

public class ChartService {
	
	private Log log = LogFactory.getLog(getClass());
	
	EntityManager em;
	CtlAudit2gRepository ctl2Audit2Repository;	
	
	public ChartService(){		
		this.em = Utilitario.getInstance().getEntityManager();
		ctl2Audit2Repository = new CtlAudit2gRepository(em);		
	}
	
	public HashMap<Integer, Integer> pointsFromCtlAudit2g(String technology){
		
		List<CtlAudit2g> result = ctl2Audit2Repository.listByCustomCriteria(technology);
		HashMap<Integer, Integer> points = new HashMap<Integer, Integer>();
				
		for (CtlAudit2g ctlAudit2g : result) {
			points.put(ctlAudit2g.getTotalCdrs(), ctlAudit2g.getTotalSeconds());
		}
				
		return points;		
	}

}
